package com.wufan.day02;

/**
 * @author SongWufan
 * @date 2021/3/5 12:21
 */
public class ArrayExec {
    public static void main(String[] args) {
        int[] array1,array2;

        array1 = new int[]{2,3,5,7,11,13,17,19};

        //显示array1
        for (int i = 0; i < array1.length; i++){
            System.out.print(array1[i] + " ");
        }

        //赋值array2等于array1
        array2 = array1;
        //数组的复制
//        array2 = new int[array1.length];
//        for (int i = 0; i < array2.length; i++){
//            array2[i] = array1[i];
//        }
        //修改array2中的偶索引，使其为索引值
        for (int i = 0; i < array2.length; i++){
            if (i % 2 == 0){
                array2[i] = i;
            }
        }
        System.out.println();
        //打印array1
        for (int i = 0; i < array1.length; i++){
            System.out.print(array1[i] + " ");
        }
    }
}
